package study.springcloud.client.feign.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import study.eggs.result.Result;
import study.eggs.result.Results;
import study.springcloud.client.feign.api.EchoApi;
import study.springcloud.client.feign.api.EchoRequest;
import study.springcloud.client.feign.client.EchoClient;

@Slf4j
@RestController
public class ClientController {

    //    @Autowired
    private EchoClient echoClient;
    @Autowired
    private EchoApi echoApi;

    @RequestMapping("/client/echo")
    public Result client() {
        EchoRequest request = new EchoRequest();
        Result result = echoClient.echo(request);
        log.info(">>>>>> {}", result);
        return Results.ok();
    }

    @RequestMapping("/api/echo")
    public Result api() {
        EchoRequest request = new EchoRequest();
        Result result = echoApi.echo(request);
        log.info(">>>>>> {}", result);
        return Results.ok();
    }
}
